export default {
	data() {
		return {

			typeList: [{
				icon: "man",
				title: "男频"
			}, {
				icon: "woman",
				title: "女频"
			}],
			selectIndex: -1,
			man: [{
					"title": "重生"
				}, {
					"title": "都市"
				}, {
					"title": "系统"
				}, {
					"title": "玄幻"
				}, {
					"title": "穿越"
				},
				{
					"title": "修仙"
				}, {
					"title": "科幻"
				}, {
					"title": "末世"
				}, {
					"title": "娱乐圈"
				}, {
					"title": "历史"
				}, {
					"title": "搞笑轻松"
				},
				{
					"title": "灵异"
				}, {
					"title": "奇幻仙侠"
				}, {
					"title": "同人"
				}, {
					"title": "网游"
				}, {
					"title": "灵气复苏"
				},
				{
					"title": "都市高武"
				}, {
					"title": "二次元"
				}, {
					"title": "校花"
				}, {
					"title": "末日求生"
				}, {
					"title": "游戏主播"
				},
				{
					"title": "开局"
				}, {
					"title": "异能"
				}, {
					"title": "抗战谍战"
				}, {
					"title": "海贼"
				}, {
					"title": "男频衍生"
				},
				{
					"title": "美食"
				}, {
					"title": "单女主"
				}, {
					"title": "科幻末世"
				}, {
					"title": "动漫衍生"
				}, {
					"title": "诸天万界"
				},
				{
					"title": "宠物"
				}, {
					"title": "盗墓"
				}, {
					"title": "召唤"
				}, {
					"title": "神医"
				}, {
					"title": "无女主"
				},
				{
					"title": "东方玄幻"
				}, {
					"title": "特种兵"
				}, {
					"title": "战神赘婿"
				}, {
					"title": "神豪"
				},
				{
					"title": "扮猪吃虎"
				}, {
					"title": "空间"
				}, {
					"title": "都市修真"
				}, {
					"title": "反派"
				}, {
					"title": "武将"
				},
				{
					"title": "星际"
				}, {
					"title": "三国"
				}, {
					"title": "鉴宝"
				}, {
					"title": "无敌"
				}, {
					"title": "风水"
				},
				{
					"title": "算命"
				}, {
					"title": "武神"
				}
			],
			woman: [{
					"title": "双男主"
				}, {
					"title": "重生"
				}, {
					"title": "穿越"
				}, {
					"title": "系统"
				}, {
					"title": "霸总"
				},
				{
					"title": "末世"
				}, {
					"title": "虐文"
				}, {
					"title": "现代言情"
				}, {
					"title": "快穿"
				}, {
					"title": "年代"
				}, {
					"title": "奇幻"
				},
				{
					"title": "病娇"
				}, {
					"title": "科幻"
				}, {
					"title": "无CP"
				}, {
					"title": "先婚后爱"
				}, {
					"title": "古代言情"
				},
				{
					"title": "历险"
				}, {
					"title": "双女主"
				}, {
					"title": "校园"
				}, {
					"title": "种田"
				}, {
					"title": "灵异"
				},
				{
					"title": "前世今生"
				}, {
					"title": "搞笑轻松"
				}, {
					"title": "女强"
				}, {
					"title": "团宠"
				}, {
					"title": "玄幻言情"
				},
				{
					"title": "民国言情"
				}, {
					"title": "动漫衍生"
				}, {
					"title": "女尊扮男装"
				}, {
					"title": "兽世"
				}, {
					"title": "宫斗宅斗"
				},
				{
					"title": "马甲"
				}, {
					"title": "空间"
				}, {
					"title": "同人"
				}, {
					"title": "真假千金"
				}, {
					"title": "红楼衍生"
				},
				{
					"title": "公版衍生"
				}, {
					"title": "萌宝"
				}, {
					"title": "甄嬛衍生"
				}, {
					"title": "穿书"
				}, {
					"title": "二次元"
				},
				{
					"title": "今穿古"
				}, {
					"title": "影视小说"
				}, {
					"title": "青梅竹马"
				}, {
					"title": "甜宠"
				}, {
					"title": "反派"
				},
				{
					"title": "现言甜宠"
				}, {
					"title": "科幻末世"
				}
			]
		}
	},
	onLoad() {
		var type = uni.getStorageSync("typeList");
		if (type && type.length > 0) {
			var list = type.split('，');
			if(list && list.length > 0) {
				var type = list[0];
				if (type == "男频") {
					this.selectIndex = 0;
					this.typeList[0].checked = true;
				}else if (type == "女频") {
					this.selectIndex = 1;
					this.typeList[1].checked = true;
				}
				if (list.length > 1) {
					list.forEach((a,index) => {
						if (index >=1) {
							if (this.selectIndex == 0) {
								 this.man.find(c => {
									return c.title == a
								}).checked = true
							}else if (this.selectIndex == 1) {
								this.woman.find(c => {
									return c.title == a
								}).checked = true
							}
						}
					})
				}
			}
		}
	},
	methods: {
		radioClick(name) {
			console.log(name)
			this.selectIndex = name;
			var typeList = JSON.parse(JSON.stringify(this.typeList))
			typeList.map((item, index) => {
				item.checked = index === name ? true : false
			})
			this.typeList = typeList;
			console.log(JSON.stringify(this.typeList))
		},
		checkboxClick(name) {
			if (this.selectIndex == 0) {
				var tagList = JSON.parse(JSON.stringify(this.man))
				tagList[name].checked = !tagList[name].checked;
				this.man = tagList;
			} else if (this.selectIndex == 1) {
				var tagList = JSON.parse(JSON.stringify(this.woman))
				tagList[name].checked = !tagList[name].checked;
				this.woman = tagList;
			}


		},
		saveInfo() {
			var types = this.typeList.filter(a => {
				return a.checked
			}).map(a => {
				return a.title
			})
			var tags = [];
			if (this.selectIndex == 0) {
				tags = this.man.filter(a => {
					return a.checked
				}).map(a => {
					return a.title
				})
			} else if (this.selectIndex == 1) {
				tags = this.tagList.filter(a => {
					return a.worman
				}).map(a => {
					return a.title
				})
			}
			
			var list = types.concat(tags);
			console.log(JSON.stringify(list))
			uni.$emit("selectType",list);
			uni.navigateBack({
				delta:1
			})
		}
	}
}